package com.tencent.sr.iris.basic.saas.service.model.advisor;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.tencent.sr.iris.activity.interfaces.response.group.operate.OperateSecondBoardResponse;
import com.tencent.sr.iris.basic.saas.common.utils.CommonUtils;
import com.tencent.sr.iris.user.core.service.interfaces.enums.UserLevelEnum;
import io.swagger.annotations.ApiModel;

import java.util.Optional;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Data
@ApiModel(value = "导师视角二级页面-(特邀会员冲刺赛)导出信息")
@Slf4j
@ColumnWidth(15)
public class AdvisorBoardSpecialSprintExportInfo {
    @ExcelProperty(value = "序号", index = 0)
    private int num;

    @ExcelProperty(value = "就位时间", index = 1)
    private String taskPhaseJoinTime;

    @ExcelProperty(value = "团长uid", index = 2)
    private String irisUid;

    @ExcelProperty(value = "union ID", index = 3)
    private String wechatUserUnionid;

    @ExcelProperty(value = "昵称", index = 4)
    private String wechatUserNickname;

    @ExcelProperty(value = "等级", index = 5)
    private String userLevel;

    @ExcelProperty(value = "贡献阶段", index = 6)
    private Integer stageNum;

    @ExcelProperty(value = "销售额", index = 7)
    private Double validGmv;

    @ExcelProperty(value = "累计销售额", index = 8)
    private Double totalValidGmv;

    @ExcelProperty(value = "收益", index = 9)
    private Double validCommissionBillCommissionFee;

    @ExcelProperty(value = "累计收益", index = 10)
    private Double totalValidCommissionBillCommissionFee;

    @ExcelProperty(value = "预估奖励金", index = 11)
    private Double predictAwardAmount;

    @ExcelProperty(value = "累计派发奖励金", index = 12)
    private Double totalAwardAmount;

    public void readFromSearchResponseData(OperateSecondBoardResponse response) {
        this.setTaskPhaseJoinTime(response.getTaskPhaseJoinTime());
        this.setIrisUid(response.getIrisUid());
        this.setWechatUserNickname(response.getWechatUserNickname());
        this.setWechatUserUnionid(response.getWechatUserUnionid());

        String levelText = Optional.ofNullable(UserLevelEnum.getByValue(response.getIrisUidLevel()))
                .map(UserLevelEnum::getDesc).orElse(StrUtil.EMPTY);
        this.setUserLevel(levelText);
        this.setStageNum(response.getStageNum());
        this.setValidGmv(CommonUtils.longToDouble(response.getValidGmv()));
        this.setTotalValidGmv(CommonUtils.longToDouble(response.getTotalValidGmv()));
        this.setValidCommissionBillCommissionFee(CommonUtils.longToDouble(
                response.getValidCommissionBillCommissionFee()));
        this.setTotalValidCommissionBillCommissionFee(CommonUtils.longToDouble(
                response.getTotalValidCommissionBillCommissionFee()));
        this.setPredictAwardAmount(CommonUtils.longToDouble(response.getPredictAwardAmount()));
        this.setTotalAwardAmount(CommonUtils.longToDouble(response.getAwardAmount()));
    }
}
